package gameObjects;

import java.io.IOException;

import logic.Coords2D;

import com.jme.math.Quaternion;
import com.jme.math.Vector3f;

public class Key extends Object3D{
	private static final long serialVersionUID = 2004101654L;
	private Coords2D coords;

	public Key(Coords2D coords) throws IOException
	{
		super(coords.toString());
		this.getModel("objects/key.jme");
		this.addTexture();
		this.model3D.setLocalScale(0.0025f);
		this.coords=coords;
		this.Place(coords.getX()+0.5f, 0.6f, coords.getY()+0.5f);
	}
	
	public void addTexture()
	{
		this.texture.setTexture("textures/gold.png", new Vector3f(1, 1, 1), false);
		this.texture.setTextureManager(this.getChildById(0));
	}
	
	private void Place(float x, float y, float z)
	{
		this.model3D.setLocalTranslation(x, y, z);
	}
	
	public void update(float tpf)
	{
		Quaternion rot = new Quaternion();
        Vector3f axis = new Vector3f( 0, 1, 0 ).normalizeLocal();
		rot.fromAngleNormalAxis( 5.5f * tpf, axis );
		this.model3D.getLocalRotation().multLocal(rot);
	}
	
	public Coords2D getCoords()
	{
		return coords;
	}
}

